<!-- 零件检测数据汇总表 -->
<template>
  <div>
    <div class="searchbox">
      <el-form :inline="true" size="small" label-width="100px">
        
            <el-form-item label="零件号">
              <el-input size="small" placeholder="零件号" v-model="form.partNumber" style="width: 140px;" ></el-input>
              <select-part-number-button @partVal="getPartVal" style="display: inline-block;margin-left: 8px;"></select-part-number-button>
              <!-- <part-number-button style="display: inline-block;"  @partVal="partVal"></part-number-button> -->
            </el-form-item>
            <el-form-item label="日期">
              <el-date-picker v-model="form.fromDate" type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder=""></el-date-picker>
            </el-form-item>
            <el-form-item label="至" label-width="25px">
              <el-date-picker v-model="form.toDate" type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder=""></el-date-picker>
            </el-form-item>
             <!-- <el-form-item label="日期:">
               <el-date-picker size="small"  :default-time="['00:00:00', '23:59:59']" value-format="yyyy-MM-dd HH:mm:ss" v-model="date" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"  style="width: 420px">
               </el-date-picker>
            </el-form-item> -->
            <el-form-item style="margin-left: 20px;">
              <el-button size="small" type="primary" @click="getExcel()">导出</el-button>
            </el-form-item>
            <el-form-item>
              <el-button size="mini" @click="clenaFrom">清除</el-button>
            </el-form-item>
          
        <!-- <jt-easy-collapse :has-expand="false">
          <template slot="expand">
            <el-form-item label="零件号">
              <el-input size="small" placeholder="零件号" v-model="form.partNumber" style="width: 140px;" ></el-input>
              <part-number-button style="display: inline-block;"  @partVal="partVal"></part-number-button>
            </el-form-item>
            <el-form-item label="日期">
              <el-date-picker v-model="form.fromDate" type="date" format="yyyy-MM-dd" placeholder=""></el-date-picker>
            </el-form-item>
            <el-form-item label="至" label-width="25px">
              <el-date-picker v-model="form.toDate" type="date" format="yyyy-MM-dd" placeholder=""></el-date-picker>
            </el-form-item>
            <el-form-item style="margin-left: 20px;">
              <el-button size="mini" type="primary" @click = "showList()">查询</el-button>
            </el-form-item>
            <el-form-item>
              <el-button size="mini">清除</el-button>
            </el-form-item>
          </template>
        </jt-easy-collapse> -->
      </el-form>
    </div>
    <!-- <div class="contentbox">
      <el-button size="small" type="primary" @click="getExcel()">导出</el-button> -->
      <!-- 表格 -->
      <!-- <h3 style="text-align: center;">零件检测数据汇总表</h3><br>
      <h3 style="text-align: center;">2018.07.07</h3><br>
      <el-table :data="tableData3" border style="width: 100%;margin: 0 auto;">
        <el-table-column prop="date" label="热处理炉号" fixed width="180"></el-table-column>
        <el-table-column prop="date" align="center" label="基础信息">
          <el-table-column prop="date" label="委托日期" width=""></el-table-column>
          <el-table-column prop="name" label="零件号" width=""></el-table-column>
          <el-table-column prop="date" label="任务类型" width=""></el-table-column>
          <el-table-column prop="date" label="零件名称" width=""></el-table-column>
          <el-table-column prop="date" label="受托方" width=""></el-table-column>
          <el-table-column prop="date" label="委托方" width=""></el-table-column>
          <el-table-column prop="date" label="零件数量" width=""></el-table-column>
          <el-table-column prop="date" label="图纸版本" width=""></el-table-column>
          <el-table-column prop="date" label="材料牌号" width=""></el-table-column>
          <el-table-column prop="date" label="委托单号" width=""></el-table-column>
          <el-table-column prop="date" label="零件图号" width=""></el-table-column>
          <el-table-column prop="date" label="样品信息" width=""></el-table-column>
          <el-table-column prop="date" label="零件状态" width=""></el-table-column>
        </el-table-column>
        <el-table-column prop="date" align="center" label="检测项目">
          <el-table-column prop="date" align="center" label="维氏硬度1" width="">
            <el-table-column prop="name" label="实测值1" width=""></el-table-column>
            <el-table-column prop="name" label="实测值2" width=""></el-table-column>
            <el-table-column prop="name" label="实测值3" width=""></el-table-column>
          </el-table-column>
          <el-table-column prop="name" align="center" label="维氏硬度2" width="">
            <el-table-column prop="name" label="实测值1" width=""></el-table-column>
            <el-table-column prop="name" label="实测值2" width=""></el-table-column>
            <el-table-column prop="name" label="实测值3" width=""></el-table-column>
          </el-table-column>
        </el-table-column>
        <el-table-column prop="date" align="center" label="检测结论"></el-table-column>
      </el-table>
    </div> -->
  </div>
</template>

<script>
import {
 getPartNumTotal,
 getPartFieldList
} from "service/task";
  import JtEasyCollapse from 'components/jt-easy-collapse/index';
  import SelectPartNumber from 'dialog/experimental-management/select-part-number-button'; // 选择零件号
  import ChoosePart from 'dialog/resource-management/part-number-button';
  export default {
    name: 'RemindingCenter',
    components: {
      'select-part-number-button': SelectPartNumber,
      'jt-easy-collapse': JtEasyCollapse,
      'part-number-button': ChoosePart,
    },
    data() {
      return {
        date:"",
        form: {
          partNumber: "",
          fromDate: "",
          toDate: "",
          partId: ""
        },
        tableData3: []
      }
    },
    mounted() {
      // this.showList();
    },
    methods: {
      // 零件号
      partVal(partNumber, partId) {
        this.form.partNumber = partNumber;
        this.form.partId = partId;
      },
      getPartVal(val) {
        // console.log(val)
        this.form.partNumber = val.partNumber;
        this.form.partId = val.id;
        // this.partName = val.partName;
        // this.graphVersion = val.graphVersion;
        // this.partGraphNumber = val.partGraphNumber;
        // this.changePart();
      },
      getExcel() {
        if (!this.form.partNumber || !this.form.fromDate || this.form.partNumber.length <= 0 || this.form.fromDate == ""||
        !this.form.toDate || this.form.toDate == "") {
          this.$message({
            type: 'error',
            message: '请选择零件号和起止时间!'
          });
          return;
        }
        window.location.href= `${process.env.API_URL}` + "report/findByPartNumTotalExcel?partNumber=" + this.form.partNumber
         + "&startDate=" + this.form.fromDate + "&endDate=" + this.form.toDate;
      },
    clenaFrom(){
      this.form= {
          partNumber: "",
          fromDate: "",
          toDate: "",
          partId: ""
        };
      this.date="";
    },
      // 表格数据展示
      showList() {
        if (!this.form.partNumber || !this.form.fromDate || this.form.partNumber.length <= 0 || this.form.fromDate == ""||
        !this.form.toDate || this.form.toDate == "") {
          this.$message({
            type: 'error',
            message: '请选择零件号和起止时间!'
          });
          return;
        }
        getPartNumTotal({
          // this.axios.get('/system/testFieldList', {
          partId: this.form.partId,
          fromDate: this.form.fromDate,
          toDate: this.form.toDate
        }).then(res => {
          this.tableData = res.data.result.list;
        });
      }
    }
  }

</script>
